﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace THenu.WMI.IPConfiguration
{
    /// <summary>
    /// 日志服务类
    /// </summary>
    public class MYLog
    {
        /// <summary>
        /// 配置日志路径
        /// </summary>
        static MYLog()
        {
            PathDirectory = string.Format("{0}\\{1}", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), System.Windows.Forms.Application.ProductName);
            PathLogFile = PathDirectory + "MYLOG.lg";
        }
        /// <summary>
        /// 默认的工作目录
        /// </summary>
        public static readonly string PathDirectory = "C:\\THenu\\";
        /// <summary>
        /// 默认路径
        /// </summary>
        private static readonly string PathLogFile = "C:\\THenu\\MYLOG.lg";
        /// <summary>
        /// 向文件写入
        /// </summary>
        /// <param name="msgContent"></param>
        public static void Log(string msgContent)
        {
            File.AppendAllText(PathLogFile, msgContent,Encoding.Unicode);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="msgContent"></param>
        /// <param name="type"></param>
        public static void Log(string msgContent, LogType type)
        {
            switch (type)
            {
                case LogType.Error:
                    Log("ERROR:->" + msgContent + Environment.NewLine);
                    break;
                case LogType.Info:
                    Log("Info:->" + msgContent + Environment.NewLine);
                    break;
                case LogType.Waring:
                    Log("Waring:->" + msgContent + Environment.NewLine);
                    break;

                default:
                    Log("LOG:->" + msgContent + Environment.NewLine);
                    break;
            }

        }
        /// <summary>
        /// 消息
        /// </summary>
        /// <param name="msgContent"></param>
        public static void Info(string msgContent)
        {
            Log(msgContent, LogType.Info);
        }
        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="msgContent"></param>
        public static void Error(string msgContent)
        {
            Log(msgContent, LogType.Info);
        }
        /// <summary>
        /// 警告
        /// </summary>
        /// <param name="msgContent"></param>
        public static void Waring(string msgContent)
        {
            Log(msgContent, LogType.Info);
        }
    }
    public enum LogType
    {
        Info,
        Error,
        Waring
    }
}
